package com.dym.staff.services;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dym.staff.dao.StaffMapper;
import com.dym.staff.entity.Staff;

@Service
public class StaffServicesImpl implements StaffServices {
	@Autowired
	StaffMapper mapper;

	@Override
	public List<Map<String, Object>> findUserName(Staff staff) {

		return mapper.findUserName(staff);
	}

	@Override
	public Map<String, Object> findID(Staff staff) {
		
		return mapper.findID(staff);
	}

	@Override
	public List<Map<String, Object>> findAll(Staff staff, int sectionID) {
		Map<String, Object> map=new HashMap<String, Object>();
		map.put("staff", staff);
		map.put("sectionID", sectionID);
		
		return mapper.findAll(map);
	}

	@Override
	public int add(Staff staff, int sectionID, int competentID) {
		mapper.add(staff);
		//mapper.findID(staff);
		System.out.println((mapper.findStaffID(staff)).getId());
		Map<String, Object> map=new HashMap<String, Object>();
		map.put("staffID", (mapper.findStaffID(staff)).getId());
		map.put("sectionID", sectionID);
		map.put("competentID", competentID);
		mapper.adds(map);
		return mapper.addss(map);
	}

}
